PROGRAM Random(input, output);
    VAR
    i, state, seed: Integer;

    FUNCTION __random_r(VAR state, retval: Integer): Integer;
    VAR
    val: Integer;
    BEGIN
        val := (8121 * state + 28411) mod 134456;
        state := val;
        retval := val;
        __random_r := 0;
    END;

    FUNCTION __random(): Integer;
    VAR
    retval: Integer;
    BEGIN
        __random_r(state, retval);
        __random := retval;
    END;

    FUNCTION srand(seed: Integer): Integer;
    BEGIN
        state := seed;
    END;

    FUNCTION rand(): Integer;
    BEGIN
        rand := __random();
    END;

    BEGIN
        read(seed);
        srand(seed);
        FOR i := 1 TO 10 DO
	        write(rand());
    END.
